import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { ListComponent } from './components/list/list.component';
import { HumanTabComponent } from './components/human-tab/human-tab.component';
import { PcTabComponent } from './components/pc-tab/pc-tab.component';
import { AreaTabComponent } from './components/area-tab/area-tab.component';
import { HumanPcListComponent } from './components/human-pc-list/human-pc-list.component';
import { HumanSoftwareListComponent } from './components/human-software-list/human-software-list.component';
import { PcExceptionListComponent } from './components/pc-exception-list/pc-exception-list.component';
import { PcUpgradeListComponent } from './components/pc-upgrade-list/pc-upgrade-list.component';
import { AreaConfigListComponent } from './components/area-config-list/area-config-list.component';
import { AreaPcListComponent } from './components/area-pc-list/area-pc-list.component';
import { AreaPrivilegeListComponent } from './components/area-privilege-list/area-privilege-list.component';
import { AreaConfigDetailComponent } from './components/area-config-detail/area-config-detail.component';

import { LogListService } from './services/log-list.service';
import { ZoneListService } from './services/zone-list.service';
import { UsbListComponent } from './components/usb-list/usb-list.component';

const routes: Routes = [
    {
        path: '',
        pathMatch: 'full',
        redirectTo: 'human/pc'
    },
    {
        path: '',
        data: {
            title: '日志管理'
        },
        component: ListComponent,
        children: [
            {
                path: 'human',
                pathMatch: 'full',
                redirectTo: 'human/pc',
            },
            {
                path: 'human',
                component: HumanTabComponent,
                data: {
                    title: '人员日志'
                },
                resolve: {
                    zone_list: ZoneListService
                },
                children: [
                    {
                        path: 'pc',
                        component: HumanPcListComponent,
                        data: {
                            title: '终端使用日志'
                        },
                        runGuardsAndResolvers: 'always',
                        resolve: {
                            list: LogListService
                        }
                    },
                    {
                        path: 'software',
                        component: HumanSoftwareListComponent,
                        data: {
                            title: '软件使用日志'
                        },
                        runGuardsAndResolvers: 'always',
                        resolve: {
                            list: LogListService
                        }
                    }
                ]
            },
            {
                path: 'pc',
                pathMatch: 'full',
                redirectTo: 'pc/exception',
            },
            {
                path: 'pc',
                component: PcTabComponent,
                data: {
                    title: '终端日志'
                },
                resolve: {
                    zone_list: ZoneListService
                },
                children: [
                    {
                        path: 'exception',
                        component: PcExceptionListComponent,
                        data: {
                            title: '终端异常日志'
                        },
                        runGuardsAndResolvers: 'always',
                        resolve: {
                            list: LogListService
                        }
                    },
                    {
                        path: 'upgrade',
                        component: PcUpgradeListComponent,
                        data: {
                            title: '终端更新日志'
                        },
                        runGuardsAndResolvers: 'always',
                        resolve: {
                            list: LogListService
                        }
                    }
                ]
            },
            {
                path: 'area',
                pathMatch: 'full',
                redirectTo: 'area/config',
            },
            {
                path: 'area',
                component: AreaTabComponent,
                data: {
                    title: '区域日志'
                },
                resolve: {
                    zone_list: ZoneListService
                },
                children: [
                    {
                        path: 'config',
                        component: AreaConfigListComponent,
                        data: {
                            title: '区域调整日志'
                        },
                        runGuardsAndResolvers: 'always',
                        resolve: {
                            list: LogListService
                        }
                    },
                    {
                        path: 'pc',
                        component: AreaPcListComponent,
                        data: {
                            title: '终端配置日志'
                        },
                        runGuardsAndResolvers: 'always',
                        resolve: {
                            list: LogListService
                        }
                    },
                    {
                        path: 'privilege',
                        component: AreaPrivilegeListComponent,
                        data: {
                            title: '权限定制日志'
                        },
                        runGuardsAndResolvers: 'always',
                        resolve: {
                            list: LogListService
                        }
                    }
                ]
            },
            {
                path: 'area/config/:id',
                data: {
                    title: '区域调整日志预览'
                },
                component: AreaConfigDetailComponent
            },
            {
                path: 'usb',
                pathMatch: 'full',
                redirectTo: 'usb/operation',
            },
            {
                path: 'usb',
                children: [{
                    path: 'operation',
                    component: UsbListComponent,
                    data: {
                        title: 'USB设备日志'
                    },
                    runGuardsAndResolvers: 'always',
                    resolve: {
                        list: LogListService
                    }
                }]
            }
        ]
    }
]

@NgModule({
    imports: [RouterModule.forChild(routes)],
    exports: [RouterModule],
})
export class LogRoutingModule { }
